<!DOCTYPE html>
<html lang="en" >
<head>
    <meta charset="UTF-8">
    <title>商品修改页面</title>
    <link rel="stylesheet" href="./src/css/layui.css"  media="all">
</head>
<body>
<form class="layui-form" style="width: 80%;" id="auf">
       <div class="layui-form-item">
          <label class="layui-form-label">商品名</label>
          <div class="layui-input-block">
            <input type="text" name="goodsName" lay-verify="required" lay-reqtext="商品名，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input">
          </div>
        </div>
		
		    <!--轮播图片  -->
		    <div class="layui-form-item">
		        <label class="layui-form-label">封面</label>
		        <div class="layui-input-block">
		            <button type="button" class="layui-btn" id="onePicUpload"><i class="layui-icon"></i>上传文件</button><br />
		            <img class="layui-upload-img" id="preview" style="width: 150px;margin-top: 5px">
		            <p id="uploadError"></p>
		            <input type="hidden" lay-verify="imgurl" name="imgurl" id="newsImg" value=""/>
		        </div>
		    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">卖家昵称</label>
        <div class="layui-input-block">
            <div style="line-height: 40PX;" class="layui-input">商品1号</div>
            <label><span style="color: red">(暂时不支持修改！)</span></label>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">库存数量</label>
        <div class="layui-input-block">
            <input type="number" id="goodsNumber" class="layui-input"
                   lay-verify="number" placeholder="输入数量" name="goodsNumber" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品价格￥</label>
        <div class="layui-input-block">
            <input type="number" id="goodsPrice" class="layui-input"
                   lay-verify="number" placeholder="输入起拍价格" name="goodsPrice" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否拍卖￥</label>
        <div class="layui-input-block">
            <input type="number" id="duringPrice" class="layui-input"
                   lay-verify="number" placeholder="输入加价幅度" name="duringPrice" value="">
        </div>
    </div>
   
      <div class="layui-form-item">
          <label class="layui-form-label">商品状态</label>
          <div class="layui-input-block">
            <input type="radio" name="sex" value="0" title="正常" checked="">
            <input type="radio" name="sex" value="1" title="不正常">
            <input type="radio" name="sex" value="2" title="冻结" >
          </div>
        </div>
  
	<div class="layui-form-item layui-form-text">
	    <label class="layui-form-label" >物品描述</label>
	    <div class="layui-input-block">
	      <textarea placeholder="请输入内容" class="layui-textarea"></textarea>
	    </div>
	  </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="addUser">立即提交</button>
        </div>
    </div>
</form>
<script src="./src/layui.js"></script>
<script>
	layui.use(['laydate','form','upload'],function(){
			var date = new Date();
			var dd = date.getFullYear();
			var mm =date.getMonth()+1;
			var aa =date.getDate();
			var h = date.getHours();
			var m = date.getMinutes();
			var s = date.getSeconds();
			var p = dd +"-"+ mm + "-"+aa + " " + h + ":" + m + ":"+ s;
		// alert(p);2020322-15-30-50  2017-8-11 12:30:00
		// var nowdate= DateTimeFormat.format(new Date());
		var laydate=layui.laydate,
		upload=layui.upload,
		form=layui.form;
		//日期时间选择器
		laydate.render({ 
		  elem: '#auctionStartTime'
		  ,type: 'datetime',
		  range:true,
		  min:p
		});
		form.render(); //更新全部
		//上传图片
		 form.verify({
		            imgurl:function (value) {
		                if(value.length == 0){
		                    return "请上传图片";
		                }
		            }
		        })
		
		        upload.render({
		            size:800000,
		            elem:'#onePicUpload', //绑定元素
		            url:'/carousel/upload',//上传图片的请求接口 ;上传成功服务器端返回文件的路径
		            before:function (obj) { //图片上传之前的回调
		                //预读本地文件，如果是多文件，则会遍历。
		                obj.preview(function (index,file,result) {//result 得到文件base64编码，比如图片
		                    //显示图片
		                    $("#preview").attr("src",result);
		                })
		            },
		            done:function (result) {
		                if(result.code == 200){
		                    layer.msg('文件上传成功',{icon:1},function () {
		                        //将服务器端返回来的图片路径，存储在隐藏域中
		                        $("#newsImg").val(result.data.src);
		                    })
		                }else{
		                    layer.msg('上传失败',{icon:5})
		                }
		            }
		        })

	})
	
</script>
</body>
</html>